package com.ctg.behavior.calc.impala.builder.usergroups;

import org.springframework.stereotype.Component;

import com.ctg.behavior.calc.impala.report.uesrgroups.CtCalcUGUBRuleReport;
import com.ctg.behavior.calc.impala.report.uesrgroups.CtCalcUGUSRuleReport;
import com.ctg.behavior.calc.impala.report.uesrgroups.CtUGUBBehaviorReport;
import com.ctg.behavior.calc.impala.report.uesrgroups.CtUGUSSequenceReport;
import com.ctg.behavior.common.calc.CtCalcUserBehavior;
import com.ctg.behavior.common.calc.CtCalcUserSequence;
import com.ctg.behavior.common.usergroups.CtUGCalcBody;
import com.ctg.behavior.common.usergroups.CtUGRuleContent;
import com.ctg.behavior.common.usergroups.CtUGUserBehaviorRule;
import com.ctg.behavior.common.usergroups.CtUGUserSequenceRule;

@Component
public class CtUGCalcReportBuilder {

	// 组建：用户行为规则对象
	public CtCalcUGUBRuleReport buildUGUBRuleReport(final CtUGCalcBody ugCalcBody) {

		CtCalcUGUBRuleReport report = new CtCalcUGUBRuleReport();

		CtUGRuleContent ugRuleContent = ugCalcBody.getRuleContentList().get(0);
		CtUGUserBehaviorRule userBehaviorRule = ugRuleContent.getUserBehaviorRule();

		report.setAppId(ugCalcBody.getAppId());
		report.setBehaviors(userBehaviorRule.getBehaviors());
		report.setRelation(userBehaviorRule.getRelation());

		return report;
	}

	// 组建：用户序列规则对象
	public CtCalcUGUSRuleReport buildUGUSRuleReport(final CtUGCalcBody ugCalcBody) {

		CtCalcUGUSRuleReport report = new CtCalcUGUSRuleReport();

		CtUGRuleContent ugRuleContent = ugCalcBody.getRuleContentList().get(0);
		CtUGUserSequenceRule userSequenceRule = ugRuleContent.getUserSequenceRule();

		report.setAppId(ugCalcBody.getAppId());
		report.setSequences(userSequenceRule.getSequences());
		report.setRelation(userSequenceRule.getRelation());

		return report;
	}

	// 组建：用户行为规则 之 一组:Behavior
	public CtUGUBBehaviorReport buildUGUBBehaviorReport(final CtCalcUserBehavior userBehavior, String appId) {

		CtUGUBBehaviorReport report = new CtUGUBBehaviorReport();

		report.setAppId(appId);
		report.setMeasures(userBehavior.getMeasures());
		report.setRelation(userBehavior.getRelation());

		return report;
	}

	// 组建：用户序列规则 之 一组:Sequence
	public CtUGUSSequenceReport buildUGUSSequenceReport(final CtCalcUserSequence userSequence, String appId) {

		CtUGUSSequenceReport report = new CtUGUSSequenceReport();

		report.setAppId(appId);
		report.setSteps(userSequence.getSteps());
		report.setTimeRestrict(userSequence.getTimeRestrict());

		return report;
	}

}
